package deltax.common.resource
{
    import deltax.common.*;
    import deltax.common.localize.*;

    final public class Enviroment extends Object
    {
        public static var ResourceRootPath:String = "";
        public static var ConfigRootPath:String = "";
        public static var PackedDataRootPath:String = "";
        public static var LanguageRelativeDir:String = "";
        public static var CurLanguage:String = Language.CN;
        public static var LoadFromPackageFirst:Boolean = false;

        public function Enviroment()
        {
            return;
        }// end function

        public static function convertURLForQueryPackage(param1:String) : String
        {
            var _loc_2:* = Util.makeGammaString(param1).replace(Enviroment.ResourceRootPath, "");
            return _loc_2.replace(Enviroment.ConfigRootPath, "");
        }// end function

        public static function getPathRelativeToRoot(param1:String) : String
        {
            return param1.replace(ResourceRootPath + "/", "");
        }// end function

        public static function convertToLocalizedUrl(param1:String) : String
        {
            var _loc_2:String = null;
            var _loc_3:String = null;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            if (CurLanguage != Language.CN)
            {
                _loc_2 = convertURLForQueryPackage(param1);
                _loc_3 = LocalizedFileMap.getFileLanguageDir(_loc_2);
                if (_loc_3 == CurLanguage)
                {
                    _loc_4 = param1.indexOf(ResourceRootPath);
                    if (_loc_4 >= 0)
                    {
                        return ResourceRootPath + LanguageRelativeDir + param1.substr(_loc_4 + ResourceRootPath.length);
                    }
                    _loc_5 = param1.indexOf(ConfigRootPath);
                    if (_loc_5 >= 0)
                    {
                        return ConfigRootPath + LanguageRelativeDir + param1.substr(_loc_5 + ConfigRootPath.length);
                    }
                }
            }
            return param1;
        }// end function

        public static function getUrlWithPostfix(param1:String, param2:String) : String
        {
            var _loc_3:* = param1.split(".");
            var _loc_4:* = _loc_3.pop();
            return _loc_3.join(".") + "_" + param2 + "." + _loc_4;
        }// end function

    }
}
